//
//  main.m
//  FileFinder
//
//  Created by hoolai on 2018/11/19.
//  Copyright © 2018年 hoolai. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "FileFinder.h"
int main(int argc, const char * argv[]) {
    @autoreleasepool {
        //NSFileManager *manager=[[NSFileManager alloc] init];
        //FileFinder *fileFinder = [[FileFinder alloc] init];
        NSString *sourcePath;
        NSLog(@"请输入源目录路径");
        char ch[100];
        scanf("%s",ch);
        sourcePath=[NSString stringWithUTF8String:ch];
        while(![[NSFileManager defaultManager] fileExistsAtPath:sourcePath]){
            NSLog(@"源路径不存在，请重新输入");
            char ch[100];
            scanf("%s",ch);
            sourcePath=[NSString stringWithUTF8String:ch];
        }
        //[fileFinder setSourcePath:path];
        NSString *targetPath;
        NSLog(@"请输入目标目录路径");
        scanf("%s",ch);
        targetPath=[NSString stringWithUTF8String:ch];
        while(![[NSFileManager defaultManager] createDirectoryAtPath:targetPath withIntermediateDirectories:YES attributes:nil error:nil]){
            NSLog(@"创建目标路径失败，请重新输入");
            char ch[100];
            scanf("%s",ch);
            targetPath=[NSString stringWithUTF8String:ch];
        }
        //设置目标目录路径
        //[fileFinder setTargetPath:path];
        //创建输出日志文件
        //新建并初始化FileFinder对象
        FileFinder *fileFinder = [[FileFinder alloc]  initWithSourcePath:sourcePath TargetPath:targetPath];
            //FileFinder *fileFinder=[[FileFinder alloc] initWithSourcePath:source TargetPath:target];
        
        //开始执行
        //写了三个小时终于迎来第一次运行
        [fileFinder copyStart];
    }
    return 0;
}
